<%@ page language="java" contentType="text/javascript; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import='java.sql.*' %>
<%@page import="java.util.ArrayList"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONSerializer"%>
<%@page import="net.sf.json.JSONArray"%>

<%String callback = request.getParameter("callback");%>
<%=callback %> (<%

	//response.setHeader("Access-Control-Allow-Origin", "*");
	//response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
	//request.setCharacterEnding("UTF-8");
	String id = request.getParameter("id");
	String cacao = request.getParameter("cacao");
	String introduction = new String(request.getParameter("introduction").getBytes("8859_1"), "utf-8");
	//String introduction = request.getParameter("introduction");
	introduction = introduction.replace("\n","<br>"); // 줄바꿈 값을 <br>로 
	introduction = introduction.replace("\u0020","&nbsp;"); // 띄어쓰기를 &nbsp;로
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	
	try{
		Class.forName("com.mysql.jdbc.Driver");
		conn = DriverManager.getConnection(
			"jdbc:mysql://localhost/itscreater", "itscreater", "campus123");
		
		String update = "update UserInfo set " +
						"Introduction:= ?, Cacao:= ?" +
						"where ID= ?;";
		pstmt = conn.prepareStatement(update);
		pstmt.setString(1, introduction);
		pstmt.setString(2, cacao);
		pstmt.setString(3, id);
		pstmt.executeUpdate();
		
		JSONObject jo = new JSONObject();		
		jo.put("success", "true");
		out.print(jo);
	}
	
	finally{
		try{
			pstmt.close();
		}
		catch (Exception ignored){
		}
		try{
			conn.close();
		}
		catch (Exception ignored){
		}
	}
%>);